import { post, get } from "../../../utils/request";
const env = import.meta.env;

const apiMail = {
  queryMailListing(data?: object) {
    return post(
      env.VITE_API_ADMIN_CONTEXT_PATH + "/admin/api/mail.listing",
      data
    );
  },
  testMail(
    sendTo: string,
    sendCC: string,
    subject: string,
    contentBase64: string
  ) {
    return post(env.VITE_API_ADMIN_CONTEXT_PATH + "/admin/api/mail.test", {
      sendTo: sendTo,
      sendCC,
      subject,
      contentBase64,
    });
  },
  getMail(mailId: string) {
    return post(env.VITE_API_ADMIN_CONTEXT_PATH + "/admin/api/mail.get", {
      mailId: mailId,
    });
  },
  getMailConfig() {
    return get(
      env.VITE_API_ADMIN_CONTEXT_PATH + "/admin/api/mail.config",
      null
    );
  },
  configMail(
    sessionId: string,
    host: string,
    port: string,
    from: string,
    user: string,
    password: string
  ) {
    return post(env.VITE_API_ADMIN_CONTEXT_PATH + "/admin/api/mail.config", {
      sessionId: sessionId,
      host,
      port,
      from,
      user,
      password,
    });
  },
};

export default apiMail;
